#include "RtpDecoder.hpp"
#include "RtpPacket.hpp"
#include "RTPDecoderHandle.hpp"
#include "StreamHelper.hpp"
#include "DepLibUV.hpp"


using namespace Hi;

RtpDecoder::RtpDecoder(){
}

RtpDecoder::~RtpDecoder() {
	if (this->streamHelper != nullptr) {
		delete this->streamHelper;
		this->streamHelper = nullptr;
	}
}

bool RtpDecoder::Start(Hi::RTPDecoderHandle& handle, uint32_t width, uint32_t height, void* option) {
	this->streamHelper = new StreamHelper(handle, width, height, option, [&](){
		//uv_async_send(&this->async);
	});
	return true;
}

void RtpDecoder::OnRtpPacket(Hi::RtpPacket *rtpPacket) {	
	//this->videoInputQueue.enqueue(this->CloneRtpPacket(rtpPacket));
	if (nullptr == this->streamHelper) {
		return;
	}
	this->streamHelper->ReceivePacket(rtpPacket);
}
void RtpDecoder::Stop() {
}